﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace MailSender
{
    public static class TemplateProcessing
    {
        /// <summary>
        /// Замена ключевых слов
        /// </summary>
        /// <param name="text"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        public static string Replace(string text, params TplElement[] args)
        {
            foreach (TplElement arg in args)
            {
                Regex rexp = new Regex(@"(\{" + arg.keyWord + @"\})");
                text = rexp.Replace(text, arg.value.ToString());
            }
            return text;
        }


    }

    public class TplElement
    {
        public string keyWord { get; set; }
        public object value { get; set; }
    }
}
